package com.xieyingwangluo.yxpart.service.impl;

import com.xieyingwangluo.yxpart.entity.WorksheetModel;
import com.xieyingwangluo.yxpart.mapper.WorksheetMapper;
import com.xieyingwangluo.yxpart.service.WorkService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class WorkServiceImpl implements WorkService {
    @Autowired
    private WorksheetMapper worksheetMapper;

    //添加工作
    @Override
    public int add(WorksheetModel work) {
        return worksheetMapper.add(work);
    }

    //模糊查询所有
    @Override
    public List<WorksheetModel> selA(WorksheetModel work) {
        return worksheetMapper.selA(work);
    }

    //根据id获取用户信息
    @Override
    public WorksheetModel getById(String noid) {
        return worksheetMapper.getById(noid);
    }

    //根据登录用户和工作状态查询工作列表
    //工作状态(0已报名，1已录用，2已完工)
    @Override
    public List<WorksheetModel> getByState(String userinfo_id, int state) {
        return worksheetMapper.getByState(userinfo_id, state);
    }

    //根据工作id修改工作状态（已录用）
    @Override
    public int updS(String noid, int state, Date record_time) {
        return worksheetMapper.updS(noid, state, record_time);
    }

    // 确认完工
    @Override
    public int updSByUser(String userinfo_id, int state, Date makespan) {
        return worksheetMapper.updSByUser(userinfo_id, state, makespan);
    }

    //更新工作（修改工作情况）
    @Override
    public int update(WorksheetModel work) {
        return worksheetMapper.update(work);
    }

    //根据part_id获取用户信息
    @Override
    public WorksheetModel getByPaId(String part_id) {
        return worksheetMapper.getByPaId(part_id);
    }

    //删除工作
    @Override
    public int del(String noid) {
        return worksheetMapper.del(noid);
    }

    //根据兼职id和用户信息详情id查询工作信息
    @Override
    public WorksheetModel getWorkByU(String part_id, String userinfo_id) {
        return worksheetMapper.getWorkByU(part_id, userinfo_id);
    }
}
